# 针对Linux的Makefile
# CC=clang
# CFLAGS=-fPIC -shared

# all: lib_hthread_sub.so

# lib_hthread_sub.so: hthread_sub.cpp hthread_sub.h
# 	$(CC) $(CFLAGS) -o lib_hthread_sub.so hthread_sub.cpp

# clean:
# 	rm -f lib_hthread_sub.so

# 针对Linux的Makefile
# CC=clang
# CXX=clang++
# CXXFLAGS=-fPIC -shared -std=c++11 -Wall
# INCLUDES = -I. -I../ -I../execution_module -I../hardware_resource -I../parsing_module -I../instruction_module

# # 添加所有必要的源文件
# SRCS = hthread_sub.cpp \
#        ../parsing_module/instr_parsing.cpp \
#        ../DSP_chip.cpp \
#        # 添加其他必要的源文件...

# OBJS = $(SRCS:.cpp=.o)

# all: lib_hthread_sub.so

# lib_hthread_sub.so: $(OBJS)
# 	$(CXX) $(CXXFLAGS) -o $@ $(OBJS)

# %.o: %.cpp
# 	$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@

# clean:
# 	rm -f lib_hthread_sub.so $(OBJS)

# CXX = g++
# CXXFLAGS = -std=c++17 -O2 -fPIC \
#     -I. -I../ -I../execution_module -I../hardware_resource -I../parsing_module -I../instruction_module -I../memory_module
# LDFLAGS = -shared

# # 可以根据需要补充所有依赖的源文件
# SRCS = $(wildcard *.cpp) \
#     ../DSP_chip.cpp \
#     ../DSP_cluster.cpp \
#     ../DSP_node.cpp \
#     ../Global.cpp \
#     ../memory_module/*.cpp \
#     ../execution_module/*.cpp \
#     ../hardware_resource/*.cpp \
#     ../hardware_resource/VPU/*.cpp \
#     ../hardware_resource/SPU/*.cpp \
#     ../parsing_module/*.cpp \
#     ../instruction_module/*.cpp

# OBJS = $(SRCS:.cpp=.o)
# TARGET = libdsp_dynamic.so

# all: $(TARGET)

# $(TARGET): $(OBJS)
# 	$(CXX) $(LDFLAGS) -o $@ $(OBJS)

# %.o: %.cpp
# 	$(CXX) $(CXXFLAGS) -c $< -o $@

# clean:
# 	rm -f $(OBJS) $(TARGET)

# .PHONY: 
# 	all clean

CXX = clang++
CXXFLAGS = -std=c++20 -O0 -fPIC -g3 -fno-eliminate-unused-debug-types\
    -I. -I../ -I../execution_module -I../hardware_resource -I../parsing_module -I../instruction_module -I../memory_module
LDFLAGS = -dynamiclib

# 收集所有源文件
SRCS = $(wildcard *.cpp) \
    ../DSP_chip.cpp \
    ../DSP_cluster.cpp \
    ../DSP_node.cpp \
    ../Global.cpp \
	../Emulator.cpp \
    $(wildcard ../memory_module/*.cpp) \
    $(wildcard ../execution_module/*.cpp) \
	$(wildcard ../execution_module/write_delay_control/*.cpp) \
    $(wildcard ../hardware_resource/*.cpp) \
    $(wildcard ../hardware_resource/VPU/*.cpp) \
    $(wildcard ../hardware_resource/SPU/*.cpp) \
    $(wildcard ../parsing_module/*.cpp) \
    $(wildcard ../instruction_module/*.cpp)

OBJS = $(SRCS:.cpp=.o)
TARGET = libdsp_dynamic.dylib
DSYM = $(TARGET).dSYM

all: $(TARGET) $(DSYM)

$(TARGET): $(OBJS)
	$(CXX) $(LDFLAGS) -g -o $@ $(OBJS) 

$(DSYM): $(TARGET)
	dsymutil $<

# 让 make 能自动生成 .o 文件
%.o: %.cpp
	$(CXX) $(CXXFLAGS) -c $< -o $@

clean:
	rm -f $(OBJS) $(TARGET)
	rm -rf $(DSYM)

.PHONY: all clean